﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Http;
namespace WebManagerSystem1.Models
{
    public class UserSession
    {
        public static int UserID
        {
            get => HttpContext.Current.Session.GetInt32("UserID").GetValueOrDefault();
            set => HttpContext.Current.Session.SetInt32("UserID", value);
        }
        public static string UserName
        {
            get => HttpContext.Current.Session.GetString("UserName");
            set => HttpContext.Current.Session.SetString("UserName", value);
        }
        public static string RealName
        {
            get => HttpContext.Current.Session.GetString("RealName");
            set => HttpContext.Current.Session.SetString("RealName", value);
        }
        public static string UserGroup
        {
            get => HttpContext.Current.Session.GetString("UserGroup");
            set => HttpContext.Current.Session.SetString("UserGroup", value);
        }
        public static string Back_Url
        {
            get => HttpContext.Current.Session.GetString("Back_Url");
            set => HttpContext.Current.Session.SetString("Back_Url", value);
        }
        /// <summary>
        /// 验证码
        /// </summary>
        public static string VerifyCode
        {
            get => HttpContext.Current.Session.GetString("VerifyCode");
            set => HttpContext.Current.Session.SetString("VerifyCode", value);
        }
        /// <summary>
        /// 是否系统管理员
        /// </summary>
        public static bool IsSystemManager
        {
            get => BaseLibrary.ClassLibrary.DataConver.ToBool(HttpContext.Current.Session.GetString("IsSystemManager"));
            set => HttpContext.Current.Session.SetString("IsSystemManager", value.ToString());
        }
        /// <summary>
        /// 退出登录
        /// </summary>
        public static void Logout()
        {
            HttpContext.Current.Session.Clear();
        }
    }
}
